/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn;

/**
 * <p>Project: app2022 - Reg5
 * <p>Powered by webrx On 2022-01-13 14:06:58
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Reg5 {
    public static void main(String[] args) {
        String str = "他的手机号是：13014577033，他在郑州。";
        System.out.println(str.matches(".*\\d.*"));
        //判断str是不是标准的手机号格式
        System.out.println(str.matches("1[3,5,8]\\d{9}"));
        //判断字符串有没有手机号
        System.out.println(str.matches(".*1[3,5,8]\\d{9}.*"));

        //是不是中文是不是一个汉字 ^开头 $代表结尾   {1}
        System.out.println("中文".matches("^[\u4e00-\u9fa5]$"));//false
        //+ {,}
        System.out.println("中文".matches("^[\u4e00-\u9fa5]+$"));//true
        System.out.println("中文".matches("[\u4e00-\u9fa5]+"));//true
        System.out.println("--".repeat(20));
        //* 代表是 {0,}
        System.out.println("中文a".matches("[\u4e00-\u9fa5]*"));//false
        System.out.println("".matches("[\u4e00-\u9fa5]*"));//true
        // ? {0,1}
        System.out.println("中".matches("[\u4e00-\u9fa5]?"));//true
        System.out.println("中文".matches("[\u4e00-\u9fa5]{2,6}"));//true
        System.out.println("**".repeat(25));
        //是不是全英文
        System.out.println("abc".matches("[a-zA-Z]+"));//true
        System.out.println("ab c".matches("[a-zA-Z]+"));//false
        System.out.println("ab123c".matches("[a-zA-Z]+"));//false
        System.out.println("abDDDc".matches("[a-zA-Z]{1,}"));//true
        System.out.println("___".repeat(20));
        //是不是全数字 "\\d+"  "\\d*"
        System.out.println("0000".matches("\\d"));//false
        System.out.println("0000".matches("\\d+"));//true
        System.out.println("0000".matches("\\d?"));//false
        System.out.println("0000".matches("\\d*"));//true


    }
}
